/**
  * Copyright 2019 bejson.com 
  */
package com.xingkeduo.dto.transter;
import com.xingkeduo.dto.QueryByUserIdResponseDto;
import com.xingkeduo.utils.DateTimeUtils;
import lombok.Data;
import org.apache.commons.lang.StringUtils;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

@Data
public class JudgementList {

    private String order_no;
    private String user_name;
    private String f_avatar;
    private String comment_time;
    private String comment;
    private String stars;
    private List<Integer> stars_arr;
    private String service_type;
    private List<String> pic_url;
    private String service_admin;


    public void covert(QueryByUserIdResponseDto queryByUserIdResponseDto){
        this.order_no = queryByUserIdResponseDto.getOrderNo();
        this.user_name=queryByUserIdResponseDto.getUserNickName();
        this.f_avatar=queryByUserIdResponseDto.getUserImg();
        this.comment_time = DateTimeUtils.yyyy_MM_dd_HH_mm(queryByUserIdResponseDto.getCreatedTime());
        this.comment=queryByUserIdResponseDto.getComment();
        this.stars = String.valueOf(queryByUserIdResponseDto.getCommentStar().getKey());
        this.stars_arr = new ArrayList<>();
        int num = 1;
        while (num<=Integer.parseInt(this.stars)){
            stars_arr.add(num);
            num++;
        }
        this.service_type =  StringUtils.isEmpty(queryByUserIdResponseDto.getServiceTypeName())?"":queryByUserIdResponseDto.getServiceTypeName();
        this.pic_url=queryByUserIdResponseDto.getPics()==null? new ArrayList<>():Arrays.asList(queryByUserIdResponseDto.getPics());
        this.service_admin=queryByUserIdResponseDto.getAdminName();

    }
}